package framework.module.easypoi.controller;

import frameworkExt.util.controller.BaseControllerExt;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@RequestMapping("")
@Controller
public class EasyPoiController extends BaseControllerExt {

    //@Action(modelName = "委托拍卖", funcName = "导入")
    /*@RequestMapping(params = "method=importData")
    @ResponseBody
    public ResponseVo importData(MultipartFile file) {
        if (file == null) return sendFail("文件为空，上传失败");

        try {
            int startRowNum = 1; //excel数据开始的行数
            ImportParams importSetting = new ImportParams(); //导入设置
            importSetting.setVerifyHandler(new IExcelVerifyHandlerImpl(startRowNum, ExcelTransformHelper.asList(TestBo.class)));

            importSetting.setNeedVerfiy(true); //需要验证
            importSetting.setTitleRows(0); //第1行为表格标题行数

            ExcelImportResult<TestBo> result = ExcelImportUtil.importExcelMore(file.getInputStream(), TestBo.class, importSetting);

            //如果有不合法的数据，前台进行提示
            if(result.isVerfiyFail()){
                StringBuilder errorMsg = new StringBuilder(500);
                result.getFailList().forEach(item -> errorMsg.append("第"+item.getRowNum()+"行:<br/> " + item.getErrorMsg() + "<br/>"));
                System.out.println(result);
                return sendFail(errorMsg.toString().replaceAll(",", ""), ResponseVo.LAYER_TYPE_OPEN);
            }
            //校验字段唯一性
            *//*StringBuilder errorMsg = _EasypoiUtil.checkPrimaryKey(service, result.getBoList(), startRowNum, "拍卖案号", "code");
            if(errorMsg.length() > 0){
                return sendFail(errorMsg.toString(), ResponseVo.LAYER_TYPE_OPEN);
            }*//*

            List<TestBo> list = result.getList();
            list.forEach(item -> {
                //item.setStatus(BusinessConstant.AUDIT_STATUS_XJ);
            });
            //service.add(list);
            return sendSuccess("成功导入" + list.size() + "条数据!", ResponseVo.LAYER_TYPE_OPEN);
        } catch (Exception e1) {
            e1.printStackTrace();
            return sendError(e.getMessage());
        }
    }*/
}
